package com.uniview.config;

import com.uniview.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author lux
 * @date: 2019/11/26
 * @desc: web相关配置
 */
@Configuration
public class WebSecurityConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Autowired
    Environment environment;

    /**
     * @desc 重新定义拦截规则
     * @param registry 拦截器注册工厂
     */
    @Override
    public  void addInterceptors(InterceptorRegistry registry) {
        //登录拦截器配置
        registry.addInterceptor(loginInterceptor)
                .excludePathPatterns(environment.getProperty("miro.filter.url").split("\\,"))
                .addPathPatterns("/**");
    }


}
